---
title: Retrieve a stored preference set
summary: GetPreferences end-to-end process on SAIF.Services.WCF.Services.PreferenceService.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-09-22
operation_id: OP-006
trigger: Caller invokes `GetPreferences` over the `PreferenceService` route.
---

# OP-006: Retrieve a stored preference set

GetPreferences is invoked over the `PreferenceService` route on `SAIF.Services.WCF.Services.PreferenceService`; this page documents the process end to end, from route dispatch to the message the caller receives.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-006 |
| **Trigger** | Caller invokes `GetPreferences` over the `PreferenceService` route. |
| **Entry operation** | [`GetPreferences`](../contracts/preference-service.md#getpreferences) |
| **Owning component** | `SAIF.Services.WCF.Services.PreferenceService.GetPreferences` |
| **Inputs** | Request message parts listed below |
| **Outputs** | The stored preference set for the application/page/user combination. |
| **Failure behavior** | Generic SOAP fault, per [Faults and error pipeline](../faults.md) |

## Request and response

| Direction | Element | Type | Declared in | Notes |
| --- | --- | --- | --- | --- |
| Request | `applicationName` | `string` | BCL (`System`) | Application name portion of the preference key; lower-cased before matching. (Yes) |
| Request | `pageName` | `string` | BCL (`System`) | Page name portion of the preference key; a blank value is normalized to the empty string. (No (default `None`)) |
| Request | `user` | `string` | BCL (`System`) | User portion of the preference key; lower-cased before matching. (Yes) |
| Response | `IDictionary<string, string>` | `IDictionary<string, string>` | BCL (`System`) | The stored preference set for the application/page/user combination. |

<!-- Types declared in `SAIF.Services.WCF.Contracts` are attributed to `SAIF.Framework.Core`, inferred from source and package references and marked `*`; their members are not enumerated because the external declaration was not read, marked `**`. -->

## Steps

1. Constructor resolves the Oracle `CLM` connection and opens a unit of work plus a `Repository<Preference>` ([BR-WCF-002](../business-rules.md#br-wcf-002-per-request-configuration-and-connection-resolution)).
2. `QueryPrefs` lower-cases `user` and `applicationName`, and normalizes a null or empty `pageName` to `string.Empty` ([BR-WCF-005](../business-rules.md#br-wcf-005-preference-keys-are-case-normalized)).
3. Query `preferenceRepository.Query().FirstOrDefault(x => x.ApplicationName.ToLower() == applicationName && (pageName.IsNullOrEmpty() ? x.PageName == null : x.PageName.ToLower() == pageName) && x.UserId.ToLower() == user)` matching application, page and user, outside any transaction.
4. If no record matches, return an empty `Dictionary<string, string>`; otherwise deserialize `PreferenceText` from JSON into `Dictionary<string, string>` ([BR-WCF-006](../business-rules.md#br-wcf-006-missing-preference-returns-an-empty-dictionary)).
   - On failure: a deserialization or Oracle exception is logged by the installed error handler and surfaced as a generic SOAP fault with exception detail included.

## Process flow

The following diagram visualizes this process's control flow.

```mermaid
flowchart TD
    A["Resolve CLM connection and<br>open Repository&lt;Preference&gt;"]
    B["Normalize applicationName,<br>pageName, and user casing"]
    C["Query preference by<br>application, page, and user"]
    C1{"Record matches?"}
    D1["No match: return an empty<br>Dictionary<string, string>"]
    D2["Match: deserialize PreferenceText from<br>JSON into Dictionary<string, string>"]
    A --> B
    B --> C
    C --> C1
    C1 -->|"No"| D1
    C1 -->|"Yes"| D2
```

## Transaction and side effects

| Aspect | Finding |
| --- | --- |
| Unit of work | `OracleUnitOfWorkFactory` (`CLM`) |
| Commit point | Not applicable — this is a read outside `Begin`/`Commit` |
| Records written | `Preference` (read only) |
| Downstream calls | None |
| Shared state touched | None |
| Repeat-call behavior | Idempotent read |

## Logging

| Surface | Written content |
| --- | --- |
| `ErrorLogErrorHandler` → `LogService` | Failure-path exception logging only, carrying method signature, calling user and exception detail; see [Faults and error pipeline](../faults.md) |

## Faults and error handling

| Failure | Fault type the caller receives | Produced by | Source |
| --- | --- | --- | --- |
| Oracle/NHibernate exception | `Generic SOAP fault` | The `ErrorLogErrorHandler` installed by `[LogErrorBehavior]` | src/WCF/SAIF.Services.WCF.Host/Services/PreferenceService.cs |
| JSON deserialization failure of `PreferenceText` | `Generic SOAP fault` | The `ErrorLogErrorHandler` installed by `[LogErrorBehavior]` | src/WCF/SAIF.Services.WCF.Host/Services/PreferenceService.cs |

## Authorization

| Requirement | Enforced by | Source | Applies to |
| --- | --- | --- | --- |
| [None in code](../authentication-authorization.md#authorization-enforcement) | IIS authentication on the deployment (see [Activation and hosting](../activation-hosting.md)) | `src/WCF/SAIF.Services.WCF.Host/Services/PreferenceService.cs` | This operation |

## Related documentation
- [Index](../index.md)
- [Overview](../overview.md)
- [Architecture](../architecture.md)
- [Activation and hosting](../activation-hosting.md)
- [Operations](../operations.md)
- [Faults and error pipeline](../faults.md)
- [Authentication and authorization](../authentication-authorization.md)
- [Dependencies](../dependencies.md)
- [Configuration](../configuration.md)
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)
- [Data model](../data-model.md)
- [Operational runbook](../operational-runbook.md)
- [Tech debt](../tech-debt.md)

> **Note:** Statements marked with `*` were inferred from code structure, naming
> conventions, or contextual evidence where direct confirmation was not available
> in source artifacts. Statements marked with `**` could not be confirmed; treat
> as unknown until verified.

## Sources
- src/WCF/SAIF.Services.WCF.Host/Services/PreferenceService.cs
